const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    entry: './src/index.js',
    output: {
      path: __dirname,
      filename: './release/bundle.js'
    },
    module:{
      rules: [{
       test:/\.js?$/,
       exclude:/(node_modules)/,
       loader: 'babel-loader'
      }]
    },
    plugins:[
      new HtmlWebpackPlugin({
        template: './index.html'
      })
    ],
    devServer:{
      contentBase:path.join(__dirname,'./release'),//本地服务获取文件的目录
      open: true, //自动打开浏览器
      port: 9000, //监听端口
      proxy:{ // 代理使能通过9000端口访问8880端口的数据 (启动服务,demo目录下执行 http-server -p  8880)
        '/api/*':{
          target:'http://localhost:8880'
        }
      }
    }
}